import torch

# tensor1.expand(size)——将tensor1扩展成size
# tensor1.expand_as(tenmsor2)——将tensor1扩展成和tensor2一样的形状
if __name__ == '__main__':
    x = torch.tensor([[1], [2], [3]])
    print('xsize：', x.size())
    print('x:', x)

    x_expand = x.expand(3, 4)
    print('x_expand:', x_expand)

    # -1代表不改变维度的大小
    x_expand = x.expand(-1, 4)
    print('x_expand', x_expand)

    x_expand_as = x.expand_as(x_expand)
    print('x_expand_as', x_expand_as)
